<template>
	<view class="down">
		<downFile
		ref="lsjUpload"
		width="100px"
		height="180rpx"
		childId="upload"
		:size="10"
		v-model="percent"
		@input="onInput"
		@callback="onCallback">
			<view class="btn" style="height: 180rpx;">选择附件上传</view>
		</downFile>
	</view>
	
</template>

<script>
	import downFile from "@/components/lsj-upload/lsj-upload"
	export default{
		data(){
			return{
				percent: ''
			}
		},
		components:{
			downFile
		},
		onReady() {
			this.onCreate();
		},
		methods:{
			onClose() {
				this.$refs.lsjUpload.close();
			},
			onCreate() {
				// 初始化参数并创建上传DOM
				this.$refs.lsjUpload.create({
					// #ifdef APP-PLUS
					cuWebview: this.$mp.page.$getAppWebview(), // app必传
					// #endif
					url: 'https://www.example.com/upload', //替换为你的接口地址
					name: 'file', // 附件key
					size: 10, // 附件上传大小上限(M)，默认10M
					debug: true,
					//根据你接口需求自定义请求头
					header: {
						'Authorization': 'token'
					},
					//根据你接口需求自定义body参数
					formData: {
						'orderId': 1000
					}
				});
			},
			onInput(e) {
				console.log('上传进度',e);
			},
			onCallback(e) {
				console.log('上传结果',e);
			}
		}
	}
</script>

<style>
</style>
